#include<bits/stdc++.h>
using namespace std;
#define ll long long
int T;
long long d[300005];
long long v[300005];
long long a[300005];
long long p[300005];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--)
    {
        int n,m;
        long long l,vv;
        cin>>n>>m>>l>>vv;
        int ans=0;
        int minnum=1e9;
        int flaga=1;
        for(int i=1;i<=n;i++)
        {
            cin>>d[i]>>v[i]>>a[i];
            if(a[i]!=0)
                flaga=0;
        }
        for(int i=1;i<=m;i++)
            cin>>p[i];
        /*if(flaga)
        {
            for(int i=1;i<=n;i++)
            {
             if(d[i]<=p[m]&&v[i]>vv)
                    ans++;
            }
            if(ans==0)
                cout<<0<<' '<<m<<endl;
            else
            cout<<ans<<' '<<m-1<<endl;
            continue;
        }*/
        for(int i=1;i<=n;i++)
        {
            if(d[i]>p[m])
                continue;
            long long nowv=v[i]*v[i]+2*a[i]*(p[m]-d[i]);
            if(nowv>vv*vv)
                ans++;
        }
        if(ans==0)
            cout<<0<<' '<<m<<endl;
        else    
            cout<<ans<<' '<<m-1<<endl;
    }
    return 0;
}